<?

function scoreBar($score)
{
	switch($score)
	{
		case 5:
			$statusdesc="Very good";
			break;
		case 4:
			$statusdesc="Not bad";
			break;
		case 3:
			$statusdesc="Normal";
			break;
		case 2:
			$statusdesc="Not good";
			break;
		case 1:
			$statusdesc="Very poor";
			break;		
	}
	return $statusdesc;

}

function postageCount($area,$total_items) {

	if($area==0)
	{
		$total_price="Invalid Area";
	}
	else
	{
		$get_place=mysql_query("select * from os_postage_setting where area_id=$area and $total_items>=from_items and $total_items<=to_items")or die(mysql_error());
						
		if(mysql_num_rows($get_place)==0)
		{
			$total_price= "0";
		}
		else
		{
			$total_price= number_format($_SESSION['currency_rate']*mysql_result($get_place,0,"total_price"),2);	
		}
		
	}
	return $total_price;
}



function billstatus_eng($statusid)
{
	switch($statusid)
	{
		case -1:
			$statusdesc="Order already expired";
			break;
		case -2:
			$statusdesc="Buyer cancelled order";
			break;
		case -3:
			$statusdesc="Pay by PayPal";
			break;
		case -4:
			$statusdesc="Pay by Credit Card, under process";
			break;	
		case 1:
			$statusdesc="Order under verifying";
			break;
		case 2:
			$statusdesc="Order verified";
			break;
		case 3:
			$statusdesc="Buyer made payment, awaiting payment verification";
			break;
		case 4:
			$statusdesc="Payment received, goods to be delivered";
			break;
		case 5:
			$statusdesc="Goods delivered";
			break;
		case 6:
			$statusdesc="Goods received";
			break;
		case 7:
			$statusdesc="Insufficient stock";
			break;
		case 8:
			$statusdesc="Merchant cancelled order";
			break;
		case 9:
			$statusdesc="Sales Closed";
			break;
		case 10:
			$statusdesc="Buyer paid with credit card, goods to be delivered";
			break;																	
		default:
			$statusdesc="Buyer didn't confirm payment method";								
	}
	
	return $statusdesc;

}




function updateInventory($pid,$total_deduct,$bid){
	$update=mysql_query("update os_products set stock_amount=stock_amount-$total_deduct where id=$pid");
	
	$system_remark=$total_deduct."item(s) deducted from stock";
	$get_latest_stock=mysql_query("select stock_amount from os_products where id=$pid");
	$insert=mysql_query("insert into os_stockrecord(pid,total_added,user_remarks,system_remarks,add_datetime,bid)values($pid,".mysql_result($get_latest_stock,0,'stock_amount').",'system generated','$system_remark',now(),$bid)")or die(mysql_error());
}

?>
